{	30 January 2011. Individual Olympiad. Problem set: http://neerc.ifmo.ru/school/io/archive/20110130/problems-individual-20110130.pdf
	Problem B
	Points: 100	
}

uses SysUtils;
var n:int64;
begin
reset(input, 'beehive.in');
rewrite(output, 'beehive.out');
readln(n);
writeln(3*n*(n-1)+1);
end.